package cn.muqingfeng.bbs.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import cn.muqingfeng.bbs.R;
import cn.muqingfeng.bbs.constants.Constants;

public class SimpleListActivity extends FragmentActivity implements OnClickListener {
	private TextView mTitleView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.simple_acitivity);
		setupViews();
	}

	private void setupViews() {
		findViewById(R.id.back).setOnClickListener(this);
		mTitleView = (TextView) findViewById(R.id.title);
		String title = getIntent().getStringExtra(Constants.EXTRA_TITLE);
		mTitleView.setText(title);
		String fragmengName = getIntent().getStringExtra(Constants.EXTRA_FRAGMENT);
		Bundle bundle = getIntent().getBundleExtra(Constants.EXTRA_BUNDLE);
		Fragment fragment = Fragment.instantiate(getApplicationContext(), fragmengName, bundle);
		FragmentManager fragmentManager = getSupportFragmentManager();
		fragmentManager.beginTransaction().add(R.id.content, fragment).commit();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.back:
			finish();
			break;

		default:
			break;
		}
	}

}
